package com.ricky.db.bll;

import com.ricky.db.DBHelper;
import com.ricky.db.model.HeroData;

public class HeroBll {

	private static String heroTable="hero";
	
	/**
	 * 通过英雄名字查询英雄数据
	 * @param heroName
	 * @return
	 */
	public static HeroData SelectHeroByName(String heroName)
	{
		HeroData hd=null;
		hd=DBHelper.queryEntity(heroTable, "{\"heroName\":\""+heroName+"\"}", HeroData.class);
		return hd;
	}
	
	/**
	 * 通过玩家登陆名字查询英雄数据
	 * @param heroName
	 * @return
	 */
	public static HeroData SelectHeroByUser(String userName)
	{
		HeroData hd=null;
		hd=DBHelper.queryEntity(heroTable, "{\"userName\":\""+userName+"\"}", HeroData.class);
		return hd;
	}
	
	/**
	 * 保持或者修改英雄数据
	 * @param hd
	 * @return
	 */
	public static Boolean saveHero(HeroData hd)
	{
		String queryJson="{\"heroName\":\""+hd.getName()+"\"}";
		hd=DBHelper.saveEntity(heroTable, queryJson, hd);
		return hd!=null;
	}
}
